package org.zecontech.plantvszombie.client.model;

import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeDeformation;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.Entity;
import org.zecontech.plantvszombie.util.Helpers;

public class SunFlowerModel<T extends Entity> extends EntityModel<LivingEntityRenderState> {

    public static final ModelLayerLocation LAYER_LOCATION =
            new ModelLayerLocation(Helpers.identifier("sun_flower"), "main");

    public final ModelPart Base;

    public final ModelPart StemBot;

    public final ModelPart StemTop;

    public final ModelPart Head;

    public SunFlowerModel(ModelPart modelPart) {
        super(modelPart);
        this.Base = root.getChild("Base");
        this.StemBot = root.getChild("StemBot");
        this.StemTop = root.getChild("StemTop");
        this.Head = root.getChild("Head");
    }

    public static LayerDefinition createBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();
        PartDefinition Base = partdefinition.addOrReplaceChild("Base",
                CubeListBuilder.create().texOffs(19, 22).addBox(-1.5F, -1.5F, -1.5F, 3.0F, 1.0F, 3.0F, new CubeDeformation(0.0F)),
                PartPose.offset(0.0F, 24.0F, 0.0F));
        PartDefinition Leaf3_r1 = Base.addOrReplaceChild("Leaf3_r1",
                CubeListBuilder.create().texOffs(0, 8).addBox(-3.0F, 0.5F, -9.0F, 6.0F, 0.0F, 8.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, -2.0F, 0.0F, -2.9671F, -0.7854F, 3.1416F));
        PartDefinition Leaf4_r1 = Base.addOrReplaceChild("Leaf4_r1",
                CubeListBuilder.create().texOffs(0, 0).addBox(-3.0F, 0.5F, -9.0F, 6.0F, 0.0F, 8.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, -2.0F, 0.0F, 0.1745F, -0.7854F, 0.0F));
        PartDefinition Leaf2_r1 = Base.addOrReplaceChild("Leaf2_r1",
                CubeListBuilder.create().texOffs(12, 0).addBox(-3.0F, 0.5F, -9.0F, 6.0F, 0.0F, 8.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, -2.0F, 0.0F, -2.9671F, 0.7854F, -3.1416F));
        PartDefinition Leaf1_r1 = Base.addOrReplaceChild("Leaf1_r1",
                CubeListBuilder.create().texOffs(12, 8).addBox(-3.0F, 0.5F, -9.0F, 6.0F, 0.0F, 8.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, -2.0F, 0.0F, 0.1745F, 0.7854F, 0.0F));
        PartDefinition StemBot = partdefinition.addOrReplaceChild("StemBot", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, 23.0F, 0.0F, -0.2618F, 0.0F, 0.0F));
        PartDefinition StemLeaf_r1 = StemBot.addOrReplaceChild("StemLeaf_r1",
                CubeListBuilder.create().texOffs(11, 25).addBox(-1.0F, -0.5F, 0.0F, 2.0F, 1.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(-1.0F, -3.0F, 0.0F, -0.49F, 0.1925F, 0.3444F));
        PartDefinition StemBot_r1 = StemBot.addOrReplaceChild("StemBot_r1",
                CubeListBuilder.create().texOffs(0, 25).addBox(-0.5F, -6.0F, -0.5F, 1.0F, 5.0F, 1.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, 1.0F, 0.0F, 0.0F, -0.7854F, 0.0F));
        PartDefinition StemTop = partdefinition.addOrReplaceChild("StemTop", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, 18.0F, 2.0F, 0.1309F, 0.0F, 0.0F));
        PartDefinition StemLeaf2_r1 = StemTop.addOrReplaceChild("StemLeaf2_r1",
                CubeListBuilder.create().texOffs(7, 25).addBox(-1.0F, -1.5F, -1.0F, 2.0F, 1.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(1.0F, -3.0F, -1.0F, 2.6217F, -0.0653F, -0.1135F));
        PartDefinition StemTop_r1 = StemTop.addOrReplaceChild("StemTop_r1",
                CubeListBuilder.create().texOffs(4, 25).addBox(-1.0F, -4.5F, -1.0F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, 1.0F, 0.0F, 0.0F, -0.7854F, 0.0F));
        PartDefinition Head = partdefinition.addOrReplaceChild("Head",
                CubeListBuilder.create().texOffs(38, 3).addBox(-5.0F, -7.0F, -2.0F, 10.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, 16.0F, 0.0F, -0.1745F, 0.0F, 0.0F));
        PartDefinition PetalsBot_r1 = Head.addOrReplaceChild("PetalsBot_r1",
                CubeListBuilder.create().texOffs(19, 16).addBox(-6.0F, 1.0F, 0.0F, 12.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0F, 0.0F, -1.0F, -0.1745F, 0.0F, 0.0F));
        PartDefinition PetalsLeft_r1 = Head.addOrReplaceChild("PetalsLeft_r1",
                CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, 0.0F, 3.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(-4.0F, -3.0F, -1.0F, 0.0F, -0.1745F, 0.0F));
        PartDefinition PetalsRight_r1 = Head.addOrReplaceChild("PetalsRight_r1",
                CubeListBuilder.create().texOffs(0, 8).addBox(1.0F, -4.0F, 0.0F, 3.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(4.0F, -3.0F, -1.0F, 0.0F, 0.1745F, 0.0F));
        PartDefinition PetalsTop_r1 = Head.addOrReplaceChild("PetalsTop_r1",
                CubeListBuilder.create().texOffs(22, 19).addBox(-6.0F, -4.0F, 0.0F, 12.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
                PartPose.offset(0.0F, -6.0F, -1.0F));
        return LayerDefinition.create(meshdefinition, 64, 64);
    }
}
